package java实验.类关系.ex03;
import java.util.Random;

public class Circles {

    public static Circle[] createCircles(int n){
        Random random = new Random();
        Circle[] circles = new Circle[n];
        for(int i=0;i<n;i++){
            circles[i] = new Circle(
                    new Point(random.nextInt(10),random.nextInt(10)),
                    random.nextDouble()*2
            );
        }
        return circles;
    }

    public static void outputCircles(Circle[] circles){
        for(Circle circle:circles){
            if(circle!=null){
                System.out.println(circle.getCircle());
            }

        }

    }

    public static Circle[] getIsolatedCircles(Circle[] circles){
        Circle[] isolatedCircles = new Circle[circles.length];
        int k=0;

        for(int i=0;i<circles.length;i++){
            boolean isIntersected=false,isContain=false;
            for(int j=0;j<circles.length;j++){
                if(i==j) continue;
                isIntersected = circles[i].isIntersected(circles[j]);
                isContain = circles[i].contains(circles[j]);
                if(isIntersected||isContain){
                    break;
                }

            }
            if(!(isIntersected||isContain)){
                isolatedCircles[k++] = circles[i];
            }
        }
        if(k>0){
            return isolatedCircles;
        }
        return null;


    }


}
